package com.esri.core.portal;

import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MapGeometry;
import com.esri.core.internal.tasks.ags.PortalFetchThumbnail;
import com.esri.core.internal.util.d;
import com.tencent.smtt.sdk.TbsVideoCacheTask;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class PortalInfo {
    private LicenseInfo B;
    private boolean C;
    final Portal a;
    boolean b;
    String c;
    String d;
    BaseMap e;
    MapGeometry f;
    String g;
    List<String> h;
    String i;
    String j;
    String k;
    String l;
    String m;
    boolean n;
    String o;
    PortalAccess p;
    PortalMode q;
    String r;
    String s;
    String v;
    HelperServices w;
    private String x;
    boolean t = true;
    boolean u = true;
    private boolean y = false;
    private boolean z = false;
    private boolean A = true;

    /* loaded from: classes.dex */
    public static class HelperServices {
        String a;
        String b;
        String c;
        ArrayList<GeocodeServiceInfo> d = new ArrayList<>();

        public String getPrintService() {
            return this.a;
        }

        public String getRouteService() {
            return this.b;
        }

        public String getGeometryService() {
            return this.c;
        }

        public List<GeocodeServiceInfo> getGeocodeServices() {
            return this.d;
        }

        public static HelperServices fromJson(JsonParser jsonParser) throws Exception {
            if (d.c(jsonParser)) {
                HelperServices helperServices = new HelperServices();
                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                    String currentName = jsonParser.getCurrentName();
                    if (currentName.equalsIgnoreCase("geocode")) {
                        if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                                helperServices.d.add(GeocodeServiceInfo.fromJson(jsonParser));
                            }
                        }
                    } else if (currentName.equalsIgnoreCase("route")) {
                        if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                                jsonParser.getCurrentName();
                                jsonParser.nextToken();
                                if (jsonParser.getCurrentName().equalsIgnoreCase(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_URL)) {
                                    helperServices.b = jsonParser.getText();
                                }
                            }
                        }
                    } else if (currentName.equalsIgnoreCase("geometry")) {
                        if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                                jsonParser.getCurrentName();
                                jsonParser.nextToken();
                                if (jsonParser.getCurrentName().equalsIgnoreCase(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_URL)) {
                                    helperServices.c = jsonParser.getText();
                                }
                            }
                        }
                    } else if (currentName.equalsIgnoreCase("printTask")) {
                        if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                                jsonParser.getCurrentName();
                                jsonParser.nextToken();
                                if (jsonParser.getCurrentName().equalsIgnoreCase(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_URL)) {
                                    helperServices.a = jsonParser.getText();
                                }
                            }
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                }
                return helperServices;
            }
            return null;
        }

        public String toString() {
            return "HelperServices [print=" + this.a + ", route=" + this.b + ", geometry=" + this.c + ", geocodeServiceInfos=" + this.d + "]";
        }
    }

    /* loaded from: classes.dex */
    public static class GeocodeServiceInfo {
        String a;
        String b;
        String c;
        String d;
        String e;
        String f;

        public String getUrl() {
            return this.a;
        }

        public String getSingleLineFieldName() {
            return this.b;
        }

        public String getNorthLat() {
            return this.c;
        }

        public String getSouthLat() {
            return this.d;
        }

        public String getEastLon() {
            return this.e;
        }

        public String getWestLon() {
            return this.f;
        }

        public static GeocodeServiceInfo fromJson(JsonParser jsonParser) throws Exception {
            if (d.c(jsonParser)) {
                GeocodeServiceInfo geocodeServiceInfo = new GeocodeServiceInfo();
                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                    String currentName = jsonParser.getCurrentName();
                    jsonParser.nextToken();
                    if (currentName.equalsIgnoreCase(TbsVideoCacheTask.KEY_VIDEO_CACHE_PARAM_URL)) {
                        geocodeServiceInfo.a = jsonParser.getText();
                    } else if (currentName.equalsIgnoreCase("singleLineFieldName")) {
                        geocodeServiceInfo.b = jsonParser.getText();
                    } else if (currentName.equalsIgnoreCase("northLat")) {
                        geocodeServiceInfo.c = jsonParser.getText();
                    } else if (currentName.equalsIgnoreCase("southLat")) {
                        geocodeServiceInfo.d = jsonParser.getText();
                    } else if (currentName.equalsIgnoreCase("eastLon")) {
                        geocodeServiceInfo.e = jsonParser.getText();
                    } else if (currentName.equalsIgnoreCase("westLon")) {
                        geocodeServiceInfo.f = jsonParser.getText();
                    } else {
                        jsonParser.skipChildren();
                    }
                }
                return geocodeServiceInfo;
            }
            return null;
        }

        public String toString() {
            return "GeocodeServiceInfo [url=" + this.a + ", northLat=" + this.c + ", southLat=" + this.d + ", eastLon=" + this.e + ", westLon=" + this.f + "]";
        }
    }

    PortalInfo(Portal portal) {
        this.a = portal;
    }

    private final String a(boolean z) {
        StringBuilder sb;
        try {
            sb = new StringBuilder();
            sb.append(this.a.findSharingUrl());
        } catch (Exception unused) {
        }
        if (z) {
            String str = this.o;
            if (str != null && str.trim().length() != 0 && !this.o.equalsIgnoreCase("null")) {
                if (this.a.isPreVersion162()) {
                    sb.append("/accounts");
                } else {
                    sb.append("/portals");
                }
                sb.append("/self/resources/");
                sb.append(this.o);
            }
            return null;
        }
        String str2 = this.l;
        if (str2 != null && str2.trim().length() != 0 && !this.l.equalsIgnoreCase("null")) {
            sb.append("/info/");
            sb.append(this.l);
        }
        return null;
        return sb.toString();
    }

    public byte[] fetchOrganizationThumbnail() throws Exception {
        String str = this.o;
        if (str == null || "null".equals(str)) {
            return null;
        }
        return new PortalFetchThumbnail(a(true), this.a.b).execute();
    }

    public byte[] fetchPortalThumbnail() throws Exception {
        String str = this.l;
        if (str == null || "null".equals(str)) {
            return null;
        }
        return new PortalFetchThumbnail(a(false), this.a.b).execute();
    }

    public static PortalInfo fromJson(JsonParser jsonParser, Portal portal) throws Exception {
        if (d.c(jsonParser)) {
            PortalInfo portalInfo = new PortalInfo(portal);
            jsonParser.enable(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS);
            jsonParser.enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS);
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if (currentName.equals("allSSL")) {
                    portalInfo.b = jsonParser.getBooleanValue();
                    if (portal != null && portal.b != null) {
                        portal.b.setSSLRequired(portalInfo.b);
                    }
                } else if (currentName.equals("basemapGalleryGroupQuery")) {
                    portalInfo.c = jsonParser.getText();
                } else if (currentName.equals("homePageFeaturedContent")) {
                    portalInfo.d = jsonParser.getText();
                } else if (currentName.equals("access")) {
                    portalInfo.p = PortalAccess.a(jsonParser.getText(), portal.isPreVersion162());
                } else if (currentName.equals("defaultBasemap")) {
                    portalInfo.e = BaseMap.fromJson(jsonParser);
                } else if (currentName.equals("defaultExtent")) {
                    portalInfo.f = GeometryEngine.jsonToGeometry(jsonParser);
                } else if (currentName.equals("description")) {
                    portalInfo.g = jsonParser.getText();
                } else if (currentName.equals("featuredGroups")) {
                    portalInfo.h = new ArrayList();
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            PortalGroup fromJson = PortalGroup.fromJson(jsonParser, portal);
                            StringBuilder sb = new StringBuilder(32);
                            if (fromJson.c != null) {
                                sb.append("title:\"");
                                sb.append(fromJson.c);
                                sb.append("\"");
                            }
                            if (fromJson.d != null) {
                                if (sb.length() > 0) {
                                    sb.append(" AND ");
                                }
                                sb.append("owner:\"");
                                sb.append(fromJson.d);
                                sb.append("\"");
                            }
                            portalInfo.h.add(sb.toString());
                        }
                    }
                } else if (currentName.equals("featuredItemsGroupQuery")) {
                    portalInfo.i = jsonParser.getText();
                } else if (currentName.equals("id")) {
                    portalInfo.j = jsonParser.getText();
                } else if (currentName.equals("name")) {
                    portalInfo.k = jsonParser.getText();
                } else if (currentName.equals("portalName")) {
                    portalInfo.m = jsonParser.getText();
                } else if (currentName.equals("portalThumbnail")) {
                    portalInfo.l = jsonParser.getText();
                } else if (currentName.equals("showHomePageDescription")) {
                    portalInfo.n = jsonParser.getBooleanValue();
                } else if (currentName.equals("thumbnail")) {
                    portalInfo.o = jsonParser.getText();
                } else if (currentName.equals("canSharePublic")) {
                    portalInfo.u = jsonParser.getBooleanValue();
                } else if (currentName.equals("canSearchPublic")) {
                    portalInfo.t = jsonParser.getBooleanValue();
                } else if (currentName.equals("portalMode")) {
                    portalInfo.q = PortalMode.a(jsonParser.getText());
                } else if (currentName.equals("urlKey")) {
                    portalInfo.r = jsonParser.getText();
                } else if (currentName.equalsIgnoreCase("customBaseUrl")) {
                    portalInfo.s = jsonParser.getText();
                } else if (currentName.equalsIgnoreCase("helperServices")) {
                    portalInfo.w = HelperServices.fromJson(jsonParser);
                } else if (currentName.equalsIgnoreCase("ipCntryCode")) {
                    portalInfo.v = jsonParser.getText();
                } else if (currentName.equalsIgnoreCase("bingKey")) {
                    portalInfo.x = jsonParser.getText();
                } else if (currentName.equalsIgnoreCase("canShareBingPublic")) {
                    portalInfo.y = jsonParser.getBooleanValue();
                } else if (currentName.equalsIgnoreCase("supportsOAuth")) {
                    portalInfo.z = jsonParser.getBooleanValue();
                } else if (currentName.equalsIgnoreCase("commentsEnabled")) {
                    portalInfo.A = jsonParser.getBooleanValue();
                } else if (currentName.equalsIgnoreCase("subscriptionInfo")) {
                    if (portalInfo.B == null) {
                        portalInfo.B = new LicenseInfo(portalInfo);
                    }
                    portalInfo.B.a(jsonParser);
                } else if (currentName.equalsIgnoreCase("isPortal")) {
                    boolean booleanValue = jsonParser.getBooleanValue();
                    portalInfo.C = booleanValue;
                    if (portalInfo.B == null && booleanValue) {
                        portalInfo.B = new LicenseInfo(portalInfo);
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            if (portalInfo.p == null) {
                portalInfo.p = PortalAccess.PUBLIC;
            }
            return portalInfo;
        }
        return null;
    }

    public Portal getPortal() {
        return this.a;
    }

    public boolean isAllSSL() {
        return this.b;
    }

    public String getBasemapGalleryGroupQuery() {
        return this.c;
    }

    public String getHomepageFeaturedContentGroupQuery() {
        return this.d;
    }

    public BaseMap getDefaultBaseMap() {
        return this.e;
    }

    public MapGeometry getDefaultExtent() {
        return this.f;
    }

    public String getOrganizationDescription() {
        return this.g;
    }

    public List<String> getFeaturedGroupsQueries() {
        return this.h;
    }

    public String getFeaturedItemsGroupQuery() {
        return this.i;
    }

    public String getOrganizationId() {
        return this.j;
    }

    public String getOrganizationName() {
        return this.k;
    }

    public String getPortalName() {
        return this.m;
    }

    public HelperServices getHelperServices() {
        return this.w;
    }

    public String getPortalThumbnailFileName() {
        return this.l;
    }

    public boolean isShowHomePageDescription() {
        return this.n;
    }

    public String getOrganizationThumbnailFileName() {
        return this.o;
    }

    public PortalAccess getAccess() {
        return this.p;
    }

    public PortalMode getPortalMode() {
        return this.q;
    }

    public String getUrlKey() {
        return this.r;
    }

    public String getCustomBaseURL() {
        return this.s;
    }

    public boolean isCanSearchPublic() {
        return this.t;
    }

    public boolean isCanSharePublic() {
        return this.u;
    }

    public String getIpCountryCode() {
        return this.v;
    }

    public String getBingKey() {
        return this.x;
    }

    public boolean isCanShareBingPublic() {
        return this.y;
    }

    public boolean isSupportsOAuth() {
        return this.z;
    }

    public boolean isCommentsEnabled() {
        return this.A;
    }

    public String toString() {
        return "PortalInfo [portal=" + this.a + ", basemapGalleryGroupQuery=" + this.c + ", homepageFeaturedContentGroupQuery=" + this.d + ", defaultBaseMap=" + this.e + ", defaultExtent=" + this.f + ", organizationDescription=" + this.g + ", featuredGroupsQueries=" + this.h + ", featuredItemsGroupQuery=" + this.i + ", organizationId=" + this.j + ", organizationName=" + this.k + ", portalThumbnailFileName=" + this.l + ", portalName=" + this.m + ", showHomePageDescription=" + this.n + ", organizationThumbnailFileName=" + this.o + ", access=" + this.p + ", portalMode=" + this.q + ", urlKey=" + this.r + ", customBaseURL=" + this.s + ", canSearchPublic=" + this.t + ", canSharePublic=" + this.u + ", ipCountryCode=" + this.v + ", helperServices=" + this.w + ", bingKey= " + this.x + ", canShareBingPublic= " + this.y + ", supportsOAuth= " + this.z + ", commentsEnabled= " + this.A + "]";
    }

    public LicenseInfo getLicenseInfo() {
        return this.B;
    }

    public boolean a() {
        return this.C;
    }
}
